package cn.com.byte1024.controller;

import cn.com.byte1024.entity.VoteLog;
import cn.com.byte1024.service.VoteLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @ProjectName: VoteSystem
 * @ClassName: VoteLogController
 * @Description:
 * @Author: Kwnda
 * @Date: 2021/1/7 0:59
 */
@Controller
@RequestMapping("/voteLog")
public class VoteLogController {

    @Autowired
    private VoteLogService voteLogService;
    
    @RequestMapping("/goVoteLogJsp")
    public String goVoteLogJsp(HttpServletRequest request, Model model){
        String userId = request.getSession().getAttribute("userId").toString();
        List<VoteLog> voteLogList=voteLogService.selectByUserId(userId);
        model.addAttribute("voteLogList",voteLogList);
        int num = voteLogList.size();
        model.addAttribute("num",num);
        return "vote-log";
    }
}
